using System;
using ValidationFramework.Reflection;

namespace ValidationFramework
{
    /// <summary>
    /// The results of any <see cref="ValidationFramework.Rule.Validate"/> operation.
    /// </summary>
    /// <remarks>An instance is only created if the <see cref="ValidationFramework.Rule.Validate"/> operation fails.</remarks>
    ///// <example>
    ///// <code source="Examples\ExampleLibraryCSharp\Reflection\GetReflectionInfoFromValidationResult.cs" title="This example shows how to get a Type or a MethodBase from a ValidationResult." lang="cs"/>
    ///// <code source="Examples\ExampleLibraryVB\Reflection\GetReflectionInfoFromValidationResult.vb"  title="This example shows how to get a Type or a MethodBase from a ValidationResult." lang="vbnet"/>
    ///// </example>
    public class ValidationError
    {
    
		// --- Constructors

        /// <remarks>
        /// null is an invalid value for any of these parameters. 
        /// Due to performance concerns <see cref="ArgumentNullException"/> will not be thrown.
        /// So just don't pass in null or an empty string.
        /// </remarks>
        /// <param name="rule">The <see cref="Rule"/> that this <see cref="ValidationResult"/> has been generated from.</param>
        /// <param name="errorMessage">The error message.</param>
		/// <param name="attemptedValue">The invalid property's value</param>
		/// <param name="propertyName">The name of the property where this <see cref="ValidationError"/> occured.</param>
		/// <param name="typeName">The name of the type who's property generated this <see cref="ValidationError"/>.</param>
        public ValidationError(string errorMessage, object attemptedValue, string propertyName, string typeName)
        {
            //Dont guard these. the performance hit is not worth the minor help it gives developers. 
            ErrorMessage = errorMessage;
			AttemptedValue = attemptedValue;
			PropertyName = propertyName;
			TypeName = typeName;
        }



		// --- Properties

        /// <summary>
		/// Gets the error message for the <see cref="ValidationError"/>.
        /// </summary>
        public string ErrorMessage
        {
			get;
			private set;
        }

		/// <summary>
		/// Gets the invalid member's value
		/// </summary>
		public object AttemptedValue
		{
			get;
			private set;
		}

        /// <summary>
		/// Gets the name of the property that this <see cref="ValidationError"/> was generated for.
        /// </summary>
		public string PropertyName { get; set; }

		/// <summary>
		/// Gets the name of the Type that this <see cref="ValidationError"/> was generated for.
		/// </summary>
		public string TypeName { get; set; }

    }
}